#!/bin/bash

# 提取x86-instructions.txt中的所有指令
cat x86-instructions.txt | grep -v '^#' | grep -v '^$' | grep -v '^##' | awk '{print $1}' > all_instructions.txt

# 提取blink-ts中已实现的指令
grep -o 'execute[A-Z][a-zA-Z]*' src/executor/InstructionExecutor.ts | sort | uniq > implemented_functions.txt

# 将函数名转换为指令名
cat implemented_functions.txt | sed 's/^execute//' | sed 's/^[a-z]/\U&/' > implemented_instructions.txt

# 找出未实现的指令
comm -23 all_instructions.txt implemented_instructions.txt > unimplemented_instructions.txt

# 清理临时文件
rm all_instructions.txt implemented_functions.txt implemented_instructions.txt

# 显示结果
cat unimplemented_instructions.txt